<?
reset ($this_folder->pimp_folders);
reset ($this_folder->pimp_files);

$unique_file_name = "";
$file_loop_index  = 0; 

$selected_file_index = $_GET["f"];
print "<table id=Tx cellspacing=0 cellpadding=0 align=left width=100%"; 
if (!$is_pocketpc) print " style='border:outset 1px'"; 
print ">"; 

// column headers
print "<tr bgcolor=$bg>"; 
if (!$is_blackberry) 
	print "    <td bgcolor='#e0e0e0' class=padded style='border-left:solid 1px white;border-right:solid 1px silver'>&nbsp;</td>";
print "    <td bgcolor='#e0e0e0' class=padded style='border-left:solid 1px white;border-right:solid 1px silver'>Name</td>";
if (!$is_pocketpc) {
	print "    <td bgcolor='#e0e0e0' class=padded style='border-left:solid 1px white;border-right:solid 1px silver' align=right>Size</td>";
	print "    <td bgcolor='#e0e0e0' class=padded style='border-left:solid 1px white;border-right:solid 1px silver'>Type</td>";
	print "    <td bgcolor='#e0e0e0' class=padded style='border-left:solid 1px white;border-right:solid 1px silver' align=right>Date</td>";
	print "    <td bgcolor='#e0e0e0' class=padded style='border-left:solid 1px white;border-right:solid 1px silver' width=100%></td>";
}
print "</tr>";  
	
	
// folder list 
while (list($folder_info_key, $folder) = each($this_folder->pimp_folders))   {   
	$abspath = $folder["path"];	 
	$file    = $folder["name"];	 
	$icon    = $folder_icons[$folder["type"]]; 
	if (!$is_blackberry) print "<tr bgcolor=silver><td nowrap colspan=6><img src='$href?i=px' height=1></td></tr>"; 
	if (!$is_blackberry) print "<tr bgcolor=white><td nowrap colspan=6><img src='$href?i=px' height=1></td></tr>"; 
	print "<tr bgcolor=white>";
	if (!$is_blackberry) 
	print "    <td class=padded bgcolor=whitesmoke width='16'><img src='$href?i=$icon'></td>";
	print "    <td class=padded nowrap bgcolor=whitesmoke><a href="; 
	if ($is_blackberry) print "'$href?d=$abspath&bkb=$bkb'"; 
	else if ($is_service) print "'javascript:fb_edit (\"d\", DIRNAME, \"rd\", \"".$abspath."\", \"f\", \"\", \"s\", \"\")'";
	else print "'javascript:gofolder(\"".$abspath."\")'";
	print ">".$file."</td>";
	if (!$is_pocketpc) {
		$caption = $folder_captions[$folder["type"]]; 
		print "    <td class=padded nowrap></td>";
		print "    <td class=padded nowrap>".$caption." Folder</td>"; 
		print "    <td class=padded nowrap>".$folder["date"]."-".$folder["type"]."</td>";
		print "    <td class=padded nowrap>".getPermissions($abspath)."</td>";
	}
	print "</tr>";  
}

// file list
if ($showlist) { 
	while (list($file_info_key, $file_info_data) = each($this_folder->pimp_files))   {   
		 
		  
		$fpath  = $file_info_data["path"];
		$fs     = $file_info_data["size"];
		$fd     = $file_info_data["date"];
		$ft     = $file_info_data["type"];
		  
		$bg = $file_loop_index==$selected_file_index?"#99CCFF":"white";
		$mg = $file_loop_index==$selected_file_index?"#99CCFF":"whitesmoke";
		if ($is_pocketpc) $file_loop_index==$selected_file_index?"#99CCFF":"white";
		
		$short = filetitle($fpath);  
		$ico = "pu"; 
		$ico=$ft=="audio/mpeg"?"po":$ico;
		$ico=$ft=="mpg"?"po":$ico;
		$ico=$ft=="nsv"?"pw":$ico;
		$ico=$ft=="mp3"?"pw":$ico;
		$ico=$ft=="ram"?"py":$ico; 
		
		$typenames = array();
		$typenames["mpg"]="Windows Media File";
		$typenames["nsv"]="Nullsoft WinAMP File";
		$typenames["mp3"]="Windows Audio File";
		$typenames["ram"]="Real Media File";
		$typenames["audio/mpeg"]="Windows Audio File";
		 
		if ($file_info_data["path"]!=$unique_file_name&&strlen($short)>0) {
		    
			 $unique_file_name=$file_info_data["path"];
			if (!$is_blackberry) print "<tr bgcolor=silver><td nowrap colspan=6><img src='$href?i=px' height=1></td></tr>"; 
			if (!$is_blackberry) print "<tr bgcolor=white><td nowrap colspan=6><img src='$href?i=px' height=1></td></tr>"; 
			print "<tr bgcolor=$bg>";
			if (!$is_blackberry) {
				print "<td class=padded bgcolor=$mg width='16'>"; 
				print "<img src='$href?i=".$ico."'>"; 
				print "</td>";
			}
			print "    <td class=padded bgcolor=$mg nowrap><a class='line' href=";
			if ($is_blackberry) print "'$href?f=$file_loop_index&d=$dirname&bkb=bkb'"; 
			else print "'javascript: goimage(\"".$file_loop_index."\")'";
			print ">".$short."</td>";
			if (!$is_pocketpc) {
				print "    <td class=padded nowrap align=right>". number_format( $fs/1000,0,"",",")." Kb</td>";
				if (array_key_exists($ft,$typenames)) {
							print "    <td class=padded nowrap>".$typenames[$ft]."</td>"; 
				} else {
							print "    <td class=padded nowrap>".$ft."</td>"; 
				
				}
				print "    <td class=padded nowrap align=right>".$fd."</td>";
				print "    <td class=padded nowrap>";
				if (file_exists($fpath)) print getPermissions($fpath);
				print "</td>";
			}
			print "</tr>"; 
		}
		$file_loop_index++;
	}	
}	 

print "</table>"; 
?>